package com.sm.filemanagelibrary.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.chad.library.adapter.base.entity.AbstractExpandableItem;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.sm.filemanagelibrary.adapter.FolderLiseAdapter;
import com.sm.filemanagelibrary.util.StringArraySort;

/**
 * created by zhud on 2019/9/29
 */
public class FolderEntity extends AbstractExpandableItem<FileEntity> implements Parcelable, MultiItemEntity, Comparable<FolderEntity> {
    public String name;

    public FolderEntity() {
    }

    public FolderEntity(String name) {
        this.name = name;
    }

    protected FolderEntity(Parcel in) {
        name = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(name);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<FolderEntity> CREATOR = new Creator<FolderEntity>() {
        @Override
        public FolderEntity createFromParcel(Parcel in) {
            return new FolderEntity(in);
        }

        @Override
        public FolderEntity[] newArray(int size) {
            return new FolderEntity[size];
        }
    };

    @Override
    public int getLevel() {
        return 0;
    }

    @Override
    public int getItemType() {
        return FolderLiseAdapter.TYPE_FOLDER;
    }

    @Override
    public int compareTo(FolderEntity o) {
        if (StringArraySort.isBiggerThan(name, o.name)) {
            return 1;
        }
        return -1;
    }
}
